package csc.fresher.spring.aspect;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class EmployeeLoggingAspect {

	@Before("execution(* csc.fresher.spring.dao.*.*(..))")
	public void beforeEmployeeMethodExecute(JoinPoint jp){
		System.out.println("Before method: " + jp.getSignature().getName());
		Object[] args = jp.getArgs();
		if(args.length == 0){
			System.out.println("No parameter");
		} else {
			for (int i = 0; i < args.length; i++) {
				System.out.println("Parameter " + (i+1) + " : " + args[i]);
			}
		}
		DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		System.out.println("DateTime: " + format.format(new Date()));
	}
}
